#!/bin/bash
if [ "$(cat /boot/config/plugins/lxc/plugin.cfg | grep -n "^SERVICE=" | cut -d '=' -f2 | sed 's/\"//g')" == "enabled" ]; then
  LXC_DATADIRECTORY="$(cat /boot/config/plugins/lxc/lxc.conf | grep -n "^lxc.lxcpath" | cut -d '=' -f2 | sed 's/\"//g')"

  if [ ! -d ${LXC_DATADIRECTORY}/cache ]; then
    mkdir -p ${LXC_DATADIRECTORY}/cache
  fi
  rm -rf /var/cache/lxc
  ln -s ${LXC_DATADIRECTORY}/cache /var/cache/lxc 2>/dev/null

  echo "/usr/local/emhttp/plugins/lxc/lxc_scripts/lxc-startup.sh" | at now >/dev/null 2>&1
fi
